package com.ruoyi.web.controller.sj.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sj.domain.WqEweiShopMember;
import com.ruoyi.sj.service.IWqEweiShopMemberService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;

/**
 * 用户 信息操作处理
 *
 * @author tyc@yanyu.com
 * @date 2018-11-28
 */
@Controller
@RequestMapping("/sj/wqEweiShopMember")
public class WqEweiShopMemberController extends BaseController {
    private String prefix = "sj/wqEweiShopMember";

    @Autowired
    private IWqEweiShopMemberService wqEweiShopMemberService;

    @RequiresPermissions("sj:wqEweiShopMember:view")
    @GetMapping()
    public String wqEweiShopMember() {
        return prefix + "/wqEweiShopMember";
    }

    /**
     * 查询用户列表
     */
    @RequiresPermissions("sj:wqEweiShopMember:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WqEweiShopMember wqEweiShopMember) {
        startPage();
        List<WqEweiShopMember> list = wqEweiShopMemberService.selectWqEweiShopMemberList(wqEweiShopMember);
        return getDataTable(list);
    }

    /**
     * 新增用户
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存用户
     */
    @RequiresPermissions("sj:wqEweiShopMember:add")
    @Log(title = "用户", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WqEweiShopMember wqEweiShopMember) {
        return toAjax(wqEweiShopMemberService.insertWqEweiShopMember(wqEweiShopMember));
    }

    /**
     * 修改用户
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        WqEweiShopMember wqEweiShopMember = wqEweiShopMemberService.selectWqEweiShopMemberById(id);
        mmap.put("wqEweiShopMember", wqEweiShopMember);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户
     */
    @RequiresPermissions("sj:wqEweiShopMember:edit")
    @Log(title = "用户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WqEweiShopMember wqEweiShopMember) {
        return toAjax(wqEweiShopMemberService.updateWqEweiShopMember(wqEweiShopMember));
    }

    /**
     * 删除用户
     */
    @RequiresPermissions("sj:wqEweiShopMember:remove")
    @Log(title = "用户", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(wqEweiShopMemberService.deleteWqEweiShopMemberByIds(ids));
    }

    /**
     * 加入黑名单
     * @param id
     * @return
     */
    @RequiresPermissions("sj:wqEweiShopMember:add")
    @PostMapping("/changeStatusById")
    @ResponseBody
    public AjaxResult changeStatusById(String id){
        return toAjax(wqEweiShopMemberService.changeStatusById(id));
    }

    /**
     * 移除黑名单
     * @param id
     * @return
     */
    @RequiresPermissions("sj:wqEweiShopMember:add")
    @PostMapping("/changeStatus")
    @ResponseBody
    public AjaxResult changeStatus(String id){
        return toAjax(wqEweiShopMemberService.changeStatus(id));
    }
}
